#include<bits/stdc++.h>
using namespace std;
int n;
struct Node{
	int v;
	double c;
}a;
stack<Node>stk;
int main(){
	freopen("simulator.in" , "r" , stdin);
	freopen("simulator.out" , "w" , stdout);
	int v0;
	double c0;
	cin >> v0 >> c0;
	a = {v0 , c0};
	stk.push(a);
	cin >> n;
	while(n--){
		char op;
		cin >> op;
		if(op == 'Z'){
			if(stk.size() > 1){
				stk.pop();
			}
		}
		else{
			int v1 , v2;
			double c1 , c2;
			cin >> v1  >> c1;
			a = stk.top();
			v2 = v1 + a.v;
			c2 = (v1 * c1 + a.c * a.v) / v2;
			Node b = {v2 , c2};
			stk.push(b);
		}
		Node x = stk.top();
		cout << x.v << " " << fixed << setprecision(5) << x.c << endl;
	}
	return 0;
}
